my_dick = {"rxy": 100, "www": 66, "xxx": 55}
print(my_dick)
# 新增元素
# 字典[key]=value
my_dick["yyy"] = 22
print(my_dick)

# 更新元素
# 字典[key]=value
my_dick["rxy"] = 99
print(my_dick)

# 删除元素
score = my_dick.pop("www")
print(my_dick)
print("score=%d" % score)

# 清空元素
my_dick.clear()
print(my_dick)

# 获取全部的key
my_dick = {"rxy": 100, "www": 66, "xxx": 55}
keys = my_dick.keys()
print(keys)

# 遍历字典
# 字典不支持下标索引，所以一般不适用while循环
for key in my_dick:
    print(key)
    print(my_dick[key])

# 统计字典内元素数量
length = int(len(my_dick))
print("字典长%d" % length)
